package cn.hadron.aa.service.impl;
import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.hadron.aa.dao.UserDao;
import cn.hadron.aa.entity.User;
import cn.hadron.aa.service.UserService;
@Service("userService")
public class UserServiceImpl extends BaseServiceImpl<User> implements UserService{
	@Autowired
	private UserDao userdao;
	@Override
	public boolean checkName(String username) {
		return userdao.getByName(username);
	}
	@Override
    public User login(String username,String password){
		User u=userdao.get(username,password);
		if(u!=null)return u;
		return null;
    }
	@Override
	public boolean regist(User user) {  
		 Serializable id=userdao.save(user);  
		 if(id!=null)return true;
		 return false;
    } 
	@Override
    public User get(Integer id){
    	return userdao.get(id);
    }
	@Override
    public void changePassword(Integer id,String password){
		User u=userdao.get(id);
		u.setPassword(password);
		userdao.update(u);
	}
}
